const input = require("scanline");
const connection = require("../db/connection");

async function chazhaoyige() {
    const mc = await input("请输入要查找的商品名称：")
    connection.query("select * from sp where 名称 = ?", [mc], function (error, qbsp) {
        if (error) {
            console.log("查找失败", error);
            process.exit(1)
        }
        if (qbsp.length <= 0) {
            console.log("没有这个商品");
            process.exit(1)
        }
        for (let sp of qbsp) {
            for (let [k, v] of Object.entries(sp)) {
                process.stderr.write(`${k}: ${v} \t`)
            }
        }

    }
    )
    connection.end()
}
module.exports = chazhaoyige